<template>
  <div class="page-sty">
    <div class="rect-area">
      <div class="img-sty">
        <img src="@/assets/images/alliance/head_peo.png" class="peo-img" alt="">
      </div>
      <div class="link" v-if="userInfo.isJoinedAlliance === 1">{{ userInfo.inviteCode }}</div>
      <div class="copy-btn" v-if="userInfo.isJoinedAlliance === 1" @click="onCopy(inviteLink)">
        {{ $t('promote.ready_to_copy') }}</div>
    </div>
    <!-- 未加入 -->
    <un-join-content v-if="userInfo.isJoinedAlliance === 0"></un-join-content>
    <!-- 已加入 -->
    <joined-content v-else></joined-content>
  </div>
</template>
<script>
import { mapState } from "vuex";
import unJoinContent from "./components/unjoin-content.vue";
import joinedContent from "./components/joined-content.vue";
export default {
  components: { unJoinContent, joinedContent },
  data() {
    return {

    }
  },
  computed: {
    ...mapState({
      config: state => state.config.config,
      userInfo: (state) => state.user.userInfo,
    }),
    inviteLink() {
      return `${this.config.webDomain}/register?inviteCode=${this.userInfo.inviteCode}`;
    },
  },
  methods: {
    onCopy(info) {
      // 复制
      let _this = this;
      this.$copyText(info).then(function () {
        _this.$Message.success(_this.$t('public.copySuccess'));
      }, function () {
        _this.$Message.error(_this.$t('public.copyFail'));
      })
    },
  }
}
</script>
<style lang="less" scoped>
.page-sty {

  .rect-area {
    height: 421px;
    background: linear-gradient(349deg, #EFAE44 0%, #FF5D97 100%);
    border-radius: 24px;
    position: relative;

    .img-sty {
      width: 100%;
      display: flex;
      justify-content: center;

      .peo-img {
        width: 622px;
      }
    }

    .link {
      min-width: 300px;
      max-width: 226px;
      white-space: nowrap;
      /* 防止文本换行 */
      overflow: hidden;
      /* 超出部分隐藏 */
      text-overflow: ellipsis;
      /* 用省略号表示超出部分 */
      padding: 9px 12px;
      background: rgba(0, 0, 0, 0.5);
      border-radius: 95px;
      font-family: PingFang SC, PingFang SC;
      font-weight: 400;
      font-size: 19px;
      color: #FFFFFF;
      line-height: 22px;
      text-align: center;
      position: absolute;
      bottom: 80px;
      right: 58px;
    }

    .copy-btn {
      min-width: 300px;
      padding: 0 8px;
      height: 44px;
      background: #FFFFFF;
      border-radius: 40px 40px 40px 40px;
      font-family: PingFang SC, PingFang SC;
      font-weight: 500;
      font-size: 19px;
      color: #1E1714;
      line-height: 22px;
      display: flex;
      align-items: center;
      justify-content: center;
      position: absolute;
      bottom: 19px;
      right: 58px;
      cursor: pointer;
    }
  }
}
</style>
